
/*
* Copyright 2009, Center for Advanced Information Systems,Nanyang Technological University
*
* File name: BuildIndexTask.java
*
* Abstract:
*
* Current Version:      0.1
* Auther:               Jin Changjiu
* Modified Date:        Jun.16,2009
*
*/
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gblend.util;

import gblend.frequentindex.*;
import org.jdesktop.application.Task;
import gblend.GBlendApp;
import gblend.db.Parameters;
import gblend.exactquery.QueryEngine;
import gblend.infrequentindex.BuildInfreqIndex;

/**
 *
 * @author cjjin
 */

public class BuildIndexTask extends Task<Void,QueryEngine> {

   private BuildFreqIndex Findex;
   private BuildInfreqIndex Infindex;
   private long time = 0;
   private Parameters para;

    public BuildIndexTask(BuildFreqIndex findex, BuildInfreqIndex infindex,Parameters parameters) {
         super(GBlendApp.getApplication());
        this.Findex=findex;
        this.Infindex=infindex;
        this.para = parameters;
    }


    @Override
    protected void failed(Throwable arg0) {
        super.failed(arg0);
        setMessage("Index built Failed: ");
    }

    @Override
    protected void succeeded(Void arg0) {
        setMessage("Index built time:"  + time+" s");
    }

    @Override
    protected Void doInBackground() throws Exception {

        setMessage("Building Index: " );
   
        Findex.build(Infindex,para);
       
       return null;
    }




}